package org.se.scut.hibernate.dao;

import java.sql.Timestamp;
import java.util.List;

import org.hibernate.Session;
import org.se.scut.hibernate.dao.model.PictureType;

public class PictureTypeDAO extends BaseDAO<PictureType> {

	public List<PictureType> getAllPictureTypes() {
		String sql = "select type from PictureType type Order by type.lastModifiedTime asc";
		return list(sql);
	}
	
	public String getLastModifiedDate(){
		String sql = "select max(type.lastModifiedTime) from PictureType type";
		Session session = HibernateSessionFactory.getSessionFactory().openSession();
		session.beginTransaction();
		String lastModifiedDate = ((Timestamp) session.createQuery(sql).uniqueResult()).toString();
		session.getTransaction().commit();
		session.close();
		return lastModifiedDate;
		
	}
	
	
}
